package com.oepm.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oepm.vo.DataVo;
import com.oepm.biz.TeaDemoFormBiz;
import com.oepm.dao.entity.QueryInfo;
import com.oepm.dao.entity.TeacherDemoApplicationPo;
import com.oepm.dao.mapper.TeaDemoFormMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TeaDemoFormBizImpl implements TeaDemoFormBiz {

    @Resource
    private TeaDemoFormMapper teaDemoFormMapper;

    @Override
    public int addTeaDemoForm(TeacherDemoApplicationPo teacherDemoApplicationPo) {
        return teaDemoFormMapper.addTeaDemoForm(teacherDemoApplicationPo);
    }

    @Override
    public DataVo selectTeaForm(String userid, QueryInfo queryInfo) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<TeacherDemoApplicationPo> teacherDemoApplicationPos = teaDemoFormMapper.selectTeaForm(userid);
        PageInfo<TeacherDemoApplicationPo> pi = new PageInfo<>(teacherDemoApplicationPos);
        return new DataVo(pi.getTotal(),pi.getList());
    }

    @Override
    public int deleteTeaDemoForm(String id) {
        return teaDemoFormMapper.deleteTeaDemoForm(id);
    }

    @Override
    public int updateTeaDemoFrom(TeacherDemoApplicationPo teacherDemoApplicationPo) {
        return teaDemoFormMapper.updateTeaDemoFrom(teacherDemoApplicationPo);
    }
}
